home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 128 #32 / q32side1.d64 / t.lil red 2 < prev    next >
Encoding:
Text File  |  1992-01-01  |  14.3 KB  |  277 lines

  1.  
  2.  
  3.               LITTLE RED READER  Version 2.00  (March 8, 1994)
  4.  
  5.         MS-DOS file reader/writer for the C128 and 1571/81/FD drives
  6.  
  7.       Program and Text by Craig Bruce  (csbruce@neumann.uwaterloo.ca)
  8.  
  9.               Interface Changed by Fender Tucker (May 8, 1996)
  10.  
  11.  
  12. 2.3. COPYING MS-DOS TO CBM-DOS
  13.  
  14. When you enter copy mode, the screen will clear and the name of each
  15. selected file is displayed as it is being copied.  If an error is
  16. encountered on either the MS-DOS or CBM-DOS drive during copying, an error
  17. message will be displayed and copying will continue (after you press a key
  18. for MS-DOS errors).
  19.  
  20. To generate a CBM-DOS filename from an MS-DOS filename, the eight filename
  21. characters are taken (including spaces) and a dot (.) and the three
  22. characters of the extension are appended.  Then, all spaces are removed,
  23. and if the name ends with a dot (.) character, then that dot character is
  24. removed as well.  I think this is fairly reasonable.
  25.  
  26. If there already is a file with the same filename on the CBM-DOS disk, then
  27. you will be prompted if you want to overwrite the file or not.  Entering an
  28. "n" will abort the copying of that file and go on to the next file, and
  29. entering a "y" (or anything else) will cause the CBM-DOS file to be
  30. "scratched" and then re-written.
  31.  
  32. The physical copying of the file is done completely in machine language and
  33. nothing is indicated on the screen while this is happening, but you can
  34. follow things by looking at das blinkin lichtes and listening for clicks
  35. and grinds. You will probably be surprised by the MS-DOS file reading speed
  36. (I mean in a good way).  The disk data is read in whole tracks and cached
  37. in memory and the directory information and the FAT are retained in memory
  38. as well.  The result is that minimal time is spent reading disk data, and
  39. no costly seeks are required for opening a new MS-DOS file.  A result is
  40. that small files are copied one after another very quickly.  You will have
  41. to wait, however, on the relatively slow standard kernel/Commodore-DOS file
  42. writing.
  43.  
  44. A few changes had to be made to the program to accomodate the RAMDOS
  45. program. RAMDOS uses memory from $2300 to $3FFF of RAM0, which is not
  46. really a good place for a device driver, and it uses some of the zero-page
  47. locations that I wanted to use.  But, difficulties were overcome.  The
  48. importance of RAMDOS compatibility is that if you only have one disk drive
  49. but you have an REU, you can use RAMDOS to store the MS-DOS files
  50. temporarily.  If you only have one disk drive and no REU, you are SOL (Out
  51. of Luck) unless you can get a RamDisk-type program for an unexpanded 128.
  52. The RAMDOS program is available from FTP site "ccosun.caltech.edu" in file
  53. "/pub/rknop/util128/ramdosii.sfx". One note I found out about RAMDOS: you
  54. cannot use a
  55.  
  56. DOPEN#1,(CF$),U(CD),W
  57.  
  58. with it like you are supposed to be able to; you have to use a
  59.  
  60. DOPEN#1,(CF$+",W"),U(CD)
  61.  
  62. Here is a table of copying speeds for copying from 1571s and 1581s with ASC
  63. and BIN translation modes.  All figures are in bytes/second.  These results
  64. were obtained from copying a 127,280 byte text file (the text of C= Hacking
  65. Issue #3).
  66.  
  67.    FROM    TO: "null"     RAMLink     RAMDOS     JD1581     JD1571
  68.   -------      ------     -------     ------     ------     ------
  69.    81-bin       5772        3441       2146        n/a        644
  70.    81-asc       5772        3434       2164        n/a        661
  71.    71-bin       4323        2991       1949       1821        n/a
  72.    71-asc       4323        2982       1962       1847        n/a
  73.  
  74. The "null" device is that "0" CBM-DOS device number, and a couple of
  75. entries are "n/a" since I only have one 1571 and one 1581.  Note that my 71
  76. and 81 are JiffyDOS-ified, so the performance of a stock 71/81 will be
  77. poorer.  JiffyDOS gives about a 2x performance improvement for the standard
  78. file accessing calls (open, close, chrin, chrout).  RAMDOS doesn't seem to
  79. be as snappy as you might think.
  80.  
  81. The "null" figures are quite impressive, but the raw sector reading speed
  82. without the overhead of mucking around with file organization is 6700
  83. bytes/sec for a 1581 and 4600 B/s for a 71.  The reason that the 1571
  84. operates so quickly is that I use a sector interleave of 4 (which is
  85. optimal) for reading the tracks.  I think that other MS-DOS file copier
  86. program uses an interleave of 1 (which is not optimal).  I lose some of the
  87. raw performance because I copy the file data internally once before
  88. outputting it (to simplify some of the code).
  89.  
  90. In a couple of places you will notice that ASC translation gives slightly
  91. better or slightly worse performance than BIN.  This is because although
  92. slightly more work is required to translate the characters, slightly fewer
  93. characters will have to be written to the CBM-DOS file, since PETSCII uses
  94. only CR where MS-DOS ASCII uses CR and LF to represent end-of-line.
  95. Translation is done by using a table (that you can change if you wish).
  96. Many entries in this table contain a value of zero, which means that no
  97. character will be output on translation.  Most of the control characters
  98. and all of the characters of value 128 (0x80) or greater are thrown away on
  99. being translated.  The table is set up so that CR characters are thrown
  100. away and the LF character is translated to a CBM-DOS CR character.  Thus,
  101. both MS-DOS ASCII files and UNIX ASCII files can be translated correctly.
  102.  
  103.  
  104. 2.4. COMMODORE-DOS MENU
  105.  
  106. The Commodore-DOS menu, which displays the names of the Commodore files
  107. selected for various operations, looks and works pretty much the same as
  108. the MS-DOS menu:
  109.  
  110.    CBMDOS  MS=10:1581  CBM=8  FREE=3211476
  111.  
  112.    NUM  S  TRN  FILENAME         T  LENGTH
  113.    ---  -  ---  ---------------- -  ------
  114.      1  *  BIN  LRR-128          P    9876
  115.      2     ASC  COM-HACKING-005  S  175412
  116.  
  117.    D - Directory  M - MS Device  F - CBM Device  C - Copy  Q=Quit
  118.    T - Toggle All  R - Remove  X - CBM Copy  / - Switch  +/- Page
  119.  
  120. You'll notice, however, that the filetype field ("T" here) is moved and is
  121. unchangable.  Also, the file lengths are not exact; they are reported as
  122. the block count of the file multiplied by 254.  This menu is not maintained
  123. for files being copied to the CBM-DOS disk from an MS-DOS disk.  You'll
  124. have to re-execute the Directory instruction to get an updated listing.
  125.  
  126. The "D" (directory) command has local effect when in this menu.  The
  127. Commodore-DOS directory will be loaded from the current CBM device number.
  128. Note that in order for this to work, the CBM device must be number eight or
  129. greater (a disk drive).  Originally, the subroutine for this command was
  130. written using only GET#'s from the disk and was very slow.  It was
  131. modified, however, to call a machine language subroutine to read the
  132. information for a directory entry from the directory listing, and hence the
  133. subroutine now operates at a tolerable speed.
  134.  
  135. The "C" (copy) command also has a different meaning when in this menu.  It
  136. means to copy the selected CBM files to the MS-DOS disk.  See details
  137. below.
  138.  
  139. The copy CBM files ("X") command is used to copy the files in the CBM-DOS
  140. menu to another CBM-DOS disk unit.  Select the files you want to copy and
  141. then press X.  You will then be asked what device number you want to copy
  142. the files to.  The device can be another disk drive or any other device
  143. (except the keyboard).  Using device number 0 does not mean the "null"
  144. device as it does with copying MS-DOS to CBM.  If you are copying to a disk
  145. device and the file already exists, then you will be asked if you wish to
  146. overwrite the file.  You cannot copy to the same disk unit.  Also, all
  147. files are copied in binary mode (regardless of what translation you have
  148. selected for a file).
  149.  
  150. The copy CBM files command was included since all of the low-level gear
  151. needed to implement it (specifically "commieIn" and "commieOut" below) was
  152. also required by other functions.  This command can be very convenient when
  153. working with RAMDOS.  For example, if you only had a 1571 as device 8 but
  154. you have a RAM expander and have installed RAMDOS as device 9, then you
  155. would copy MS-DOS files to RAMDOS using the MS-DOS menu, and then you would
  156. go to the Commodore-DOS menu ("/"), read the directory, select all files,
  157. insert an Commodore-DOS diskette into your 1571, and then use "X" to copy
  158. from the RAMDOS device to the 1571.
  159.  
  160. The remove command ("R") does not work for this directory.  You can SCRATCH
  161. your CBM-DOS files your damn self.
  162.  
  163.  FENDER'S NOTE: Hey, I thought only Knees Calhoon had the nerve to say
  164. stuff like that.
  165.  
  166.  
  167. 2.5. COPY CBM-DOS TO MS-DOS
  168.  
  169. Before you can copy selected CBM-DOS files to an MS-DOS disk, the MS-DOS
  170. disk directory must be already loaded (from the MS-DOS menu).  This is
  171. required since the directory and FAT information are kept in memory at all
  172. times during the execution of this program.
  173.  
  174. When you enter copy mode, the screen will clear and the name of each
  175. selected file is displayed as it is being copied.  If an error is
  176. encountered on either the MS-DOS or CBM-DOS drive during copying, an error
  177. message will be displayed and copying will continue (after you press a key
  178. for MS-DOS errors).  Please note that not a whole lot of effort was put
  179. into error recovery.
  180.  
  181. To generate an MS-DOS filename from an CBM-DOS filename, the following
  182. algorithm is used.  The filename is searched from right to left for the
  183. last "." character.  If there is no "." character, then the entire
  184. filename, up to 11 characters, is used as the MS-DOS filename.  Characters
  185. 9 to 11 will be used as the extension.  If there is a "." character, then
  186. all characters before it, up to eight, will be used as the MS-DOS filename
  187. and all characters after the final ".", up to three, will be used as the
  188. MS-DOS extension.
  189.  
  190. Then, the newly generated MS-DOS filename is scanned for any extra "."
  191. characters or embedded spaces.  If any are found, they are replaced by the
  192. underscore character, which is the backarrow character on a Commodore
  193. display.  Finally, all trailing underscores are removed from the end of
  194. both the filename and extension portions of the MS-DOS filename.  Also, all
  195. characters are converted to lowercase PETSCII (which is uppercase ASCII)
  196. when they are copied into the MS-DOS filename.  Note that if the Commodore
  197. filename is not in the 8/3 format of MS-DOS, then something in the name may
  198. be lost. Some examples of filename conversion follow:
  199.  
  200.  CBM-DOS FILENAME       MS-DOS FILENAME
  201.  ----------------       ---------------
  202.  "lrr.bin"              "lrr.bin"
  203.  "lrr.128.bin"          "lrr 128.bin"
  204.  "hello there.text"     "hello th.tex"
  205.  "long filename"        "long fil.ena"
  206.  
  207. It would have been time-consuming to have the program scan the MS-DOS
  208. directory for a filename already existing on the disk, so LRR will put
  209. multiple files on a disk with the same filename without complaining.  This
  210. also gets rid of the problem of asking you if you want to overwrite the old
  211. file or generate a new name.  However, in order to retrieve the file from
  212. disk on an MS-DOS machine, you will probably have to use the RENAME command
  213. to rename the first versions of the file on the disk to something else so
  214. MS-DOS will scan further in the directory for the last version of the file
  215. with the same filename.  There is no rename command in LRR because I never
  216. thought of it in time.  It would have been fairly easy to put in.
  217.  
  218. The date generated for a new MS-DOS file will be all zeros.  Some systems
  219. interpret this as 12:00 am, 01-Jan-80 and others don't display a date at
  220. all for this value.
  221.  
  222. The physical copying of the file is done completely in machine language and
  223. nothing is displayed on the screen while this is happening, but you can
  224. follow things by looking at the blinking lights and listening for clicks
  225. and grinds.
  226.  
  227. Since the FAT and directory are maintained in RAM during the entire copying
  228. process and are only flushed to disk after the entire batch of files are
  229. copied, copying is made more efficient, since there will be no costly seek
  230. back to track 0 after writing each file (like MS-DOS does).  If you have a
  231. number of small files to copy, then they will be knocked off in quick
  232. succession, faster than many MS-DOS machines will copy them.
  233.  
  234. To simplify the implementation, the current track of disk blocks for
  235. writing is not maintained like it is for reading.  Also, a writing
  236. interleave of 1:1 is used for a 1571, which is not optimal.  However, since
  237. writing is such a slow operation anyway, and since the 1571 is particularly
  238. bad by insisting on verifying blocks, not much more overhead is introduced
  239. than is already present.
  240.  
  241. An interesting note about writing MS-DOS disks is that you can terminate
  242. LRR in the middle of a copy (with STOP+RESTORE) or in the middle of copying
  243. a batch of files, and the MS-DOS disk will remain in a perfectly consistent
  244. state afterwards.  The state will be as if none of the files were copied.
  245. The reason is that the control information (the FAT and directory) is
  246. maintained internally and is flushed only after copying is all completed.
  247. But don't terminate LRR while it is flushing the control information.
  248.  
  249.  FENDER'S NOTE: I removed the "Flushing" message, so let's just say "Don't
  250. terminate LRR while it is accessing the drives in any way."
  251.  
  252. Here is a table of copying speeds for copying to 1571, 1581, and CMD FD-
  253. 4000 disk units with ASC and BIN translation modes.  All figures are in
  254. bytes/ second, which includes both reading the byte from a C= disk and
  255. writing it to the MS-DOS disk.  The average speed for either the read or
  256. write operation individually will be twice the speed given below.  These
  257. results were obtained from copying a 156,273 byte text file (the text of C=
  258. Hacking Issue #4).
  259.  
  260.  FROM    TO: FD-bin     FD-asc     81-bin     81-asc    71-bin    71-asc
  261.  --------    ------     ------     ------     ------    ------    ------
  262.  RAMLink      2,332      2,200      2,332      2,200     1,594     1,559
  263.  RAMDOS       1,070      1,053      1,604      1,600     1,561     1,510
  264.  FD4000           -          -      1,645      1,597     1,499     1,464
  265.  JD1581       1,662      1,619          -          -     1,474     1,440
  266.  JD1571       1,050      1,024        953        933         -         -
  267.  
  268. These figures are for transfer speed only, not counting the couple of
  269. seconds of opening files and flushing the directory.  Note that all my
  270. physical drives are JiffyDOS-ified, so your performance may be slower.  I
  271. am at a loss to explain why an FD-4000 is so much slower than a 1581 for
  272. copying from a RAMDOS file, but the same speed or better for copying from
  273. anything else.
  274.  
  275.                         \\\\\ RETURN - Menu \\\\\
  276.                                                                            
  277.